# 3.11 Pressure Sensor ## 3.11.1 Overview BMP388 pressure sensor is a pneumatic MEMS sensor a very compact package, featuring small size, low power consumption but high performance. In brief, it is a combination of the temperature and pressure sensor, which is perfect for mobile applications. This module adopts proven piezoresistive pressure sensing technology with high accuracy and linearity, as well as long-term stability and high EMC stability. Besides, it maximize flexibility in multi-device working, and is ideal for altitude tracking in consumer electronics drones, wearables, smart homes, etc. As for improvement, we can optimize the device in terms of power consumption, resolution and filtering performance. ## 3.11.2 Schematic Diagram ![6-11](./media/6-11-2.png) Based on piezoelectric pressure sensing technology, the BMP388 pressure sensor accurately measures pressure and temperature. It is capable of measuring air pressure in the 300 ~ 1250 hPa range without consuming much power (consuming only 3.4 µA at 1 Hz operating frequency). In addition, the built-in infinite impulse response filter can effectively reduce effects from external interference. ## 3.11.3 Code Blocks 1. ![j35](./media/j35.png) This block initializes the BMP388 pressure sensor. Without this block, the module will not work. 2. ![j36](./media/j36.png) This block reads BMP388 sensor values. If the values are not read, they cannot be output. 3. ![j37](./media/j37.png) This block outputs the values read by BMP388 sensor, including Pressure, Altitude and Temperature. ![j38](./media/j38.png) ## 3.11.4 Test Code ### 3.11.4.1 Build Code There are two ways to upload the code: directly open the code file we provide; or manually build blocks. **Directly open the code file we provide:** 1. Click ![](./media/j68.png) and choose `Load from your computer` ![](./media/j67.png) 2. We have already downloaded the codes on computer desktop, so open the file and choose `3-11-bmp388.sb3` **Manually build blocks:** 1. In ![events](./media/events.png), find ![j1](./media/j1.png) block. 2. In ![](./media/bmp388.png), find and put ![j35](./media/j35.png) under ![j1](./media/j1.png). 3. In ![serial](./media/serial.png), drag ![j12](./media/j12.png) and set baud rate to 9600, and put it under ![j35](./media/j35.png). 4. In ![control](./media/control.png), drag ![j2](./media/j2.png).![6-4-4-1-1](./media/6-2-4-1-1.png) ![6-2](./media/6-2-4-1-2.png) 4. In ![](./media/bmp388.png), put ![j13](./media/j36.png) in ![j2](./media/j2.png) 5. In ![serial](./media/serial.png), put ![j13](./media/j13.png) under![](./media/j36.png) and set to print “Pressure:” in no-warp mode. 6. Add one more ![image-20240701141959486](./media/6-9-4-1-1.png) block and set to no-warp 7. In ![](./media/bmp388.png), drag and put ![j14](./media/j37.png) block in the printing content of ![j13](./media/6-9-4-1-1.png) and set to show “Pressure:” values. ![6-11](./media/6-11-4-1-1.png) 8. Duplicate ![6-11](./media/6-11-4-1-2.png) and set to print “ Altitude:”(the two spaces separates the two values to be output). Modify to show data “Altitude”. 9. Duplicate ![6-11](./media/6-11-4-1-3.png) and set to print “ Temperature:” (the two spaces separates the two values to be output). Modify to show data “°C”. 10. Set ![6-11](./media/6-11-4-1-4.png) to print in warp mode. 11. Add a delay of 1S for better observing the results. **Complete Test Code** ![6-11-4-1-5](./media/6-11-4-1-5.png) ### 3.11.4.2 Test Result After uploading code, the serial monitor prints the values read by BMP388 sensor. ![6-11](./media/6-11-4-2.png)